import java.lang.reflect.Array;
import java.util.Arrays;

public class Test {
    public static int[] find(int[] array,int key){
        int[] a = {-1,-1};
        for (int i = 0; i < array.length; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if((array[i] + array[j]) == key){
                    a[0] = i;
                    a[1] = j;
                    return a;
                }
            }
        }
        return a;
    }
    public static void main(String[] args) {
        int[] arr = {2,7,11,15};
        int[] a = find(arr,9);
        System.out.println(Arrays.toString(a));

    }
    public static void change(int[] array){
        int l = 0;
        int r = array.length-1;
        while(l < r){
            if(array[l] % 2 == 1){
                l++;
                }
            if(array[r] % 2 == 0){
                r--;
            } else if ((array[l] % 2 != 1) && (array[r] % 2 != 0)) {
                int tmp = 0;
                tmp = array[l];
                array[l] = array[r];
                array[r] = tmp;
                l++;
                r--;
            }
        }
    }
    public static void main14(String[] args) {
        int[] arr = {1,2,3,4,5,6};
        change(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void transform(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            arr[i] = arr[i] * 2;
        }
    }
    public static void main12(String[] args) {
        int[] array = {1,2,3};
        transform(array);
        System.out.println(Arrays.toString(array));
    }
    public static void move2(char c1,char c2){
        System.out.print(c1+"->"+c2+" ");
    }
    public static void move3(int n,char c1,char c2,char c3){//移动个数，起始位置，中专位置，目标位置
        if(n == 1){
            move2(c1,c3);
        }
        else {
            move3(n-1,c1,c3,c2);
            move2(c1,c3);
            move3(n-1,c2,c1,c3);
        }
    }

    public static void main11(String[] args) {
        char a = '1';
        char b = '2';
        char c = '3';
        move3(3,a,b,c);
    }
    public static int[] bubble_sort(int[] array){
        for (int i = 0; i < array.length-1; i++) {
            for (int j = 0;j < array.length-1-i;j++){
                if(array[j] > array[j+1]){
                    int tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1]  = tmp;
                 }
            }
        }
        return array;
    }
    public static void main10(String[] args) {
        int[] arr = {2,4,5,121,5,7,9,3,5,7};
        int[] a = bubble_sort(arr);
        System.out.println(Arrays.toString(a));
    }
    public static int binarySearch(int[] arry,int key) {
        int left = 0;
        int right = arry.length;
        int mid = 0;
        int flag = -1;
        while (left <= right) {
            mid =( left + right) / 2;
            if (arry[mid] > key) {
                right = mid - 1;
            } else if (arry[mid] < key) {
                left = mid + 1;
            } else if (arry[mid] == key) {
                flag = 0;
                return mid;

            }
        }
        return flag;
    }

    public static void main13(String[] args) {
         int[] arry = {1,2,3,4,5,6,7};
        System.out.println(binarySearch(arry,5));
    }
    public static String myToString(int[] arry){
        String str="[";
        for (int i = 0; i < arry.length; i++) {
            if(i == arry.length - 1)
            {
                str = str + arry[i]+"";
                break;
            }
            str = str + arry[i]+" ,";
        }
        str = str + "]";
        return  str;
    }
    public static void main7(String[] args) {
        int [] arry = {1,2,3,4,5};

        System.out.println(myToString(arry));
    }
    public  static int func1(int n){
        if(n == 1 || n == 2) return 1;
        return func1(n-1)+func1(n-2);
    }
    public static void main6(String[] args) {
        int x = func1(40);
        System.out.println(x);
    }
    public static int max(int a,int b){
        if(a > b){
            return a;
        }
        return b;
    }
    public static double max(double a,double b,double c){
        if(a > b) {
            if (a > c) return a;
            return c;
        }
        else {
            if (b > c) return b;
            return c;
        }
    }
    public static void main5(String[] args) {
        int x = max(1,2);
        double y = max(1.0f,2.0f,3.0f);
        System.out.println(x+" "+y);
    }


    public static  int add(int a,int b){
        return a + b;
    }
    public static  double add(double a,double b,double c){
        return a + b + c ;
    }
    public static void main4(String[] args) {
        int x = add(1,2);
        double y = add(1.0f,2.0f,3.0f);
        System.out.println(x+" "+y);
    }
    public static  int max3(int a,int b,int c){
        int x = max2(a,b);
        if(x > c) return x;
        return c;
    }
    public static  int max2(int a,int b){
        if(a > b) return a;
        return b;
    }
    public static void main2(String[] args) {
        int i = max2(1,2);
        int j = max3(1,2,3);
        System.out.println(i+" "+j);
    }

    public static int func(int n){
        if(n < 10) {
            return n;
        }else{
            return n %10+func(n / 10);
        }


    }
    public static void main1(String[] args) {
        int n = func(1729);
        System.out.println(n);
    }
}
